package com.aurora.oa.work.adapter;

import android.content.Context;
import android.net.Uri;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.aurora.oa.R;
import com.facebook.drawee.view.SimpleDraweeView;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/4/18 0018.
 */
public class ImageSeeAdapter extends BaseAdapter {
    Context context;
    List<String> uriList;

    public ImageSeeAdapter(Context context, List<String> uriList) {
        this.context = context;
        this.uriList = uriList;
    }

    @Override
    public int getCount() {
        return uriList.size();
    }

    @Override
    public String getItem(int i) {
        return uriList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder;
        if (view == null) {
            view = View.inflate(context, R.layout.item_image, null);
            viewHolder = new ViewHolder(view);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
        viewHolder.sdvImg.setImageURI(uriList.get(i));

        return view;
    }

    static class ViewHolder {
        @Bind(R.id.sdv_img)
        SimpleDraweeView sdvImg;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
